<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home v-if="type === 'home'"></home>
    <kind v-else-if="type === 'kind'"></kind>
    <cart v-else-if="type === 'cart'"></cart>
    <user v-else></user>
    <ul>
      <li @click="changeTitle('home')">首页</li>
      <li @click="changeTitle('kind')">分类</li>
      <li @click="changeTitle('cart')">购物车</li>
      <li @click="changeTitle('user')">我的</li>
    </ul>
  </div>
</body>
<template id="content">
  <div>
    {{ msg }}
  </div>
</template>
<script src="lib/vue.js"></script>
<script>
  const Home = {
    template: `<div>首页</div>`
  }
  const Kind = {
    template: `<div>分类</div>`
  }
  const Cart = {
    template: `<div>购物车</div>`
  }
  const User = {
    template: `<div>我的</div>`
  }

  new Vue({
    el: '#app',
    data: {
      type: 'home'
    },
    components: {
      Home: Home,
      Kind: Kind,
      Cart: Cart,
      User: User
    },
    methods: {
      changeTitle (type) {
        this.type = type
      }
    },
  })
</script>
</html>